# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=glm
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.9.7.5
pkgrel=1
pkgdesc="C++ mathematics library for 3D software based on the OpenGL Shading Language (GLSL) specification (mingw-w64)"
arch=('any')
url='http://glm.g-truc.net'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("https://github.com/g-truc/${_realname}/releases/download/${pkgver}/${_realname}-${pkgver}.zip")
sha256sums=('f39a908c6519e70ea1e91a8732e69aed84d28c46bc01cc3dedf71ca88b06716f')

build() {
  cd ${srcdir}/${_realname}
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && \
     rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DGLM_TEST_ENABLE=ON \
    ../${_realname}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/doc
  cp -r $srcdir/${_realname}/doc \
   ${pkgdir}${MINGW_PREFIX}/share/doc/glm
  rm -f ${pkgdir}${MINGW_PREFIX}/include/glm/CMakeLists.txt
  find ${pkgdir}${MINGW_PREFIX} -type f -exec chmod 644 {} \;
  find ${pkgdir}${MINGW_PREFIX} -type d -exec chmod 755 {} \;

  #install -Dm644 ${srcdir}/${_realname}/util/FindGLM.cmake ${pkgdir}${MINGW_PREFIX}/share/cmake-3.2/Modules/FindGLM.cmake
  install -Dm644 ${srcdir}/${_realname}/copying.txt \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

